CREATE TABLE [dbo].[PRODUCTOS]
(
[ID] [numeric] (10, 0) NOT NULL,
[CODIGO] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ID_MARCA] [numeric] (10, 0) NOT NULL,
[ID_MEDIDA] [numeric] (10, 0) NOT NULL,
[ID_ORIGINAL] [numeric] (10, 0) NOT NULL,
[UBICACION] [varchar] (70) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_PRODUCTOS_UBICACION] DEFAULT (''),
[COSTO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_PRODUCTOS_COSTO] DEFAULT ((0)),
[PRECIO] [numeric] (10, 2) NOT NULL,
[X_GANANCIA] [numeric] (10, 4) NOT NULL CONSTRAINT [DF_PRODUCTOS_X_GANANCIA] DEFAULT ((0)),
[EXISTENCIA] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_PRODUCTOS_EXISTENCIA] DEFAULT ((0)),
[MINIMO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_PRODUCTOS_MINIMO] DEFAULT ((0)),
[MAXIMO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_PRODUCTOS_MAXIMO] DEFAULT ((0)),
[IMPUESTOS] [bit] NOT NULL CONSTRAINT [DF_PRODUCTOS_IMPUESTOS] DEFAULT ((1)),
[DESCUENTO] [bit] NOT NULL CONSTRAINT [DF_PRODUCTOS_DESCUENTO] DEFAULT ((1)),
[SERVICIO] [bit] NOT NULL CONSTRAINT [DF_PRODUCTOS_SERVICIO] DEFAULT ((0)),
[ACTIVO] [bit] NOT NULL CONSTRAINT [DF_PRODUCTOS_ACTIVO] DEFAULT ((1))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PRODUCTOS] ADD CONSTRAINT [PK_PRODUCTOS] PRIMARY KEY CLUSTERED  ([ID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PRODUCTOS] ADD CONSTRAINT [IX_PRODUCTOS] UNIQUE NONCLUSTERED  ([CODIGO]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_PRODUCTOS_1] ON [dbo].[PRODUCTOS] ([CODIGO], [ACTIVO]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_PRODUCTOS_MARCA] ON [dbo].[PRODUCTOS] ([ID_MARCA]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_PRODUCTOS_ORIGINAL] ON [dbo].[PRODUCTOS] ([ID_ORIGINAL]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PRODUCTOS] ADD CONSTRAINT [FK_PRODUCTOS_MARCAS] FOREIGN KEY ([ID_MARCA]) REFERENCES [dbo].[MARCAS] ([ID])
GO
ALTER TABLE [dbo].[PRODUCTOS] ADD CONSTRAINT [FK_PRODUCTOS_MEDIDAS] FOREIGN KEY ([ID_MEDIDA]) REFERENCES [dbo].[MEDIDAS] ([ID])
GO
ALTER TABLE [dbo].[PRODUCTOS] ADD CONSTRAINT [FK_PRODUCTOS_ORIGINALES] FOREIGN KEY ([ID_ORIGINAL]) REFERENCES [dbo].[ORIGINALES] ([ID])
GO
